package designpatterns.responsibility.chain.code.log;

/**
 * 模板方法
 */
public abstract class LogPrintTemplate extends AbstractLoggerChain {

    @Override
    void doPrint(Log log) {
        if (super.logLevel.equals(log.getLevel())) {
            process(log);
        } else {
            AbstractLoggerChain nextLevel = getNextLevel();
            if (nextLevel == null) {
                throw new RuntimeException("无对应的处理器!");
            }
            nextLevel.doPrint(log);
        }
    }

    abstract void process(Log log);
}
